<!--跨项目调整审核页面-->
<template>
    <view class="body" :class="type === 'todo' ? '':'done'" v-if="flag">
        <ProjectBackInfo :prjDetail="prjDetail"></ProjectBackInfo>
        <ProjectPreInfo :prjDetail="prjDetail"></ProjectPreInfo>
        <MaterialInfo :prjDetail="prjDetail"></MaterialInfo>
        <AttachMentInfo :attachMentObj="attachmentInfo" :showSign="false"></AttachMentInfo>
        <jn-approval-detail :processInstID="processInstId" :prj-type="prjDetail.prjType"></jn-approval-detail>
        <button-view :workDetail="workDetail" :prjDetail="prjDetail" :selectUser="selectUser" :buttonList="buttonList" :status="status" @popClose="handleBack({userName: '', userId: '' })" v-if="type === 'todo'"></button-view>
    </view>
</template>


<script>
import ProjectPreInfo from "@/inspur/adjustProject/components/projectPreInfo.vue";
import ProjectBackInfo from "@/inspur/adjustProject/components/projectBackInfo.vue";
import MaterialInfo from "@/inspur/adjustProject/components/materialInfo.vue";
import ButtonView from "@/inspur/adjustProject/components/buttonView.vue";
import AttachMentInfo from "@/inspur/attachmentinfo/index.vue";
import JnApprovalDetail from "@/component/jn/JnApprovalDetail.vue";
export default{
    components: {
        JnApprovalDetail,
        ProjectPreInfo,
        ProjectBackInfo,
        MaterialInfo,
        AttachMentInfo,
        ButtonView
    },
    data(){
        return {
            type:'todo',
            attachmentInfo:{},
            processInstId:'',
            workItemId:'',
            status: true, //是否是发起
            workDetail:{},
            prjDetail:{},
            bizSeq:'',
            selectUser:{},
            buttonList:[],
            flag:false,
        }
    },
    onLoad(option) {
        this.type = option.type;
        this.$set(this.attachmentInfo,'type',option.type)
        this.status = option.status === '1'
        this.workItemId = option.workItemId
        //根据发起判断按钮显示
        if(this.status){
            //页面跳转的发起页面
            let sysToken = uni.getStorageSync("sysToken")
            this.$set(this.attachmentInfo,'sysToken',sysToken)
        }else{
            //待办、已办进来的审核页面
            uni.setStorageSync("sysToken", option.sysToken)
            this.$set(this.attachmentInfo,'sysToken',option.sysToken)
        }
        this.getWorkItemId();
    },
    methods:{
        getWorkItemId(){
            this.$axios.get('/acceptance/api/accept/commonAcceptance/getWFWorkItem',{workItemId:this.workItemId}).then((res)=>{
                this.workDetail=res.data;
                this.bizSeq= res.data.bizObject?.bizSeq;
                this.$set(this.attachmentInfo, 'prjId', res.data.bizObject?.bizSeq)
                this.$set(this.attachmentInfo, 'prjStage', res.data.bizObject?.wfStage)
                this.$set(this.attachmentInfo, 'nodeId', res.data.bizObject?.nodeCode)
                this.$set(this.attachmentInfo, 'activityId', res.data.bizObject?.nodeCode)
                this.processInstId=res.data.processInstID
                this.getProjectInfo(res.data.bizObject?.bizSeq)
                if(this.status || res.data.activityDefID === 'adjust_prj1'){
                    this.buttonList = [
                        { button:'下一步', method:'assign' },
                        { button:'取消', method:'close'}
                    ]
                }else{
                    this.buttonList = [
                        { button:'下一步', method:'assign' },
                        { button:'回退', method:'doBack'},
                        { button:'关闭', method:'doClose'}
                    ]
                }
            })
        },
        getProjectInfo(bizSeq){
            this.$axios.post('/material/api/flows/adjustPrjFlow/queryAdjustPrjFlowInfo?bizSeq='+bizSeq).then((res)=>{
                this.prjDetail = res.data
                this.$set(this.attachmentInfo, 'prjType', res.data.prjType)
                this.$set(this.attachmentInfo, 'buildModes', res.data.buildModes)
                this.$set(this.attachmentInfo, 'towerType', res.data.towerType)
                this.$set(this.attachmentInfo, 'roomType', res.data.roomType)
                this.$set(this.attachmentInfo, 'orgId', res.data.orgId)
                this.$set(this.attachmentInfo, 'isChange', '0')
                this.flag=true
            })
        },
        handleBack(obj){
            this.selectUser=obj;
        }
    }
}
</script>

<style scoped lang="scss">
.body {
    width: 100%;
    box-sizing: border-box;
    background: #f7f8fa;
    padding:20rpx 20rpx 150rpx;
}
.done{
    padding:20rpx !important;
}
</style>